package com.choosefine.common.utils;

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import java.io.IOException;
import java.net.URL;
import java.util.Properties;

/**
 * @Author Ye_Wenda
 * @Date 4/8/2017
 */
public class PropertiesUtil {

    public static Properties getProperties() throws IOException {
        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        URL ymlUrl = PropertiesUtil.class.getResource("/properties.yml");
        yaml.setResources(resolver.getResources(ymlUrl.toString()));
        return yaml.getObject();
    }
}
